' Hello World Script

Private Sub Command1_Click()

  Dim appRef As Photoshop.Application
  Dim docRef As Photoshop.Document
  Dim artLayerRef As Photoshop.ArtLayer
  Dim textItemRef As Photoshop.TextItem
  Dim layerKind As Photoshop.PsLayerKind
  Dim textColor As Photoshop.SolidColor

  Set appRef = New Photoshop.Application
  Dim strtRulerUnits As PsUnits
  Dim strtTypeUnits As PsTypeUnits
  strtRulerUnits = appRef.Preferences.RulerUnits
  appRef.Preferences.RulerUnits = psInches
  strtTypeUnits = appRef.Preferences.TypeUnits
  appRef.Preferences.TypeUnits = psTypePoints

  Set textColor = New Photoshop.SolidColor
  textColor.RGB.Red = 255
  textColor.RGB.Green = 0
  textColor.RGB.Blue = 0

  'Create a new document and assign it to a variable.
  Set docRef = appRef.Documents.Add(7, 5)

  'Create a new art layer, set it to a text layer.
  Set artLayerRef = docRef.ArtLayers.Add

  layerKind = psTextLayer
  artLayerRef.Kind = layerKind

  'Set the contents and other properties of the text layer.
  Set textItemRef = artLayerRef.TextItem
  textItemRef.Contents = "Hello, World!"
  textItemRef.Position = Array(0.75, 0.75)
  textItemRef.Size = 36
  textItemRef.Font = "Georgia"
  textItemRef.Color = textColor

  appRef.Preferences.RulerUnits = strtRulerUnits
  appRef.Preferences.TypeUnits = strtTypeUnits
End Sub
